<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .red {
            color: red;
        }

        .fontSize {
            font-size: 100px;
        }

        .bgc {
            background-color: green;
        }


        .textColor {
            color: #f00;
            /* background-color: #eef; */
        }

        .textSize {
            font-size: 30px;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div id="app">

        <div class="red fontSize" @click='changeClass'> {{msg}} </div>

        <hr>
        <!-- v-bind:class="{key:val,key2:val2  }"     key 表示我们的样式类名   val 布尔变量 如果为真 则表示添加对应的样式  为false 则不添加 -->
        <div :class="{fontSize:isActive1, bgc:isActive2  }" @click='changeClass'> {{msg}} </div>
        <!--  数组的语法 -->
        <div :class="[fontsize,textColor]" @click='changeClass'> {{msg}} </div>


        <div :class="[fontsize,textColor,{bgc:isActive2}]" @click='changeClass'>  数组与对象混合使用：  {{msg}} </div>
        <hr>
    </div>
    <script src="./vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                msg: '  动态 绑定class 样式 ',
                isActive1: true,
                isActive2: true,
                fontsize: 'fontSize',
                textColor:'textColor'
            },
            methods: {

                changeClass() {
                    // this.isActive1=false
                    // this.isActive2=true
                    this.isActive1 = !this.isActive1
                    this.isActive2 = !this.isActive2


                }
            }
        });
    </script>
</body>

</html>